package chixing.day01;

public class ArrayDemo {
    static int[] a = {48, 62, 63, 826, 73, 48, 12, 66, 19, 30};

    public static int problem1() {
        return a.length;
    }
    public static int problem2() {
        return a[6];
    }
    public static boolean problem3() {
        return a[6] == 37;
    }
    public static boolean problem4() {
        for (int i = 0; i < a.length; i++) {
            if (a[i] == 37) {
                return true;
            }
        }
        return false;
    }
    public static void problem5() {
        int temp = a[0];
        a[0] = a[1];
        a[1] = temp;
        for (int i = 0; i < a.length; i++) {
            System.out.print(a[i]);
            System.out.print(" ");

        }
        System.out.println();
    }
    public static void problem6() {
        int temp = a[0];
        a[0] = a[a.length - 2];
        a[a.length - 2] = temp;
        for (int i = 0; i < a.length; i++) {
            System.out.print(a[i]);
            System.out.print(" ");

        }
        System.out.println();
    }
    public static int[] problem7() {
        int[] b = new int[a.length];
        for (int i = 0; i < a.length; i++) {
            b[i] = a[i];
            System.out.print(b[i]);
            System.out.print(" ");

        }
        System.out.println();
        return b;
    }
    public static int[] problem8() {
        int[] b = new int[a.length];
        for (int i = 0; i < a.length; i++) {
            b[i] = a[a.length - 1 - i];
            System.out.print(b[i]);
            System.out.print(" ");
        }
        System.out.println();
        return b;
    }
    public static int[] problem9() {
        int[] b = new int[a.length];
        for (int i = 0; i < a.length; i++) {
            b[i] = a[i];
        }
        for (int i = 0; i < a.length; i++) {
            for (int j = i + 1; j < a.length; j++) {
                if (b[i] > b[j]) {
                    int temp = b[i];
                    b[i] = b[j];
                    b[j] = temp;
                }
            }
        }
        for (int i = 0; i < a.length; i++) {
            System.out.print(b[i]);
            System.out.print(" ");
        }
        System.out.println();
        return b;
    }
    public static void problem10() {
        for (int i = 0; i <= 100; i++) {
            if (i % 2 == 0) {
                System.out.print(i);
                System.out.print(",");
            }
        }
        System.out.println();
    }

    public static int[] problem11() {
        int[] x = {10,20,30,40};
        int[] y = new int[x.length + 1];
        for (int i = 0; i < 3; i++) {
            y[i] = x[i];
        }
        y[3] = 33;
        y[4]= 40;
        for (int i = 0; i < 5; i++) {
            System.out.print(y[i]);
            System.out.print(' ');
        }
        System.out.println();
        return y;
    }
    public static int problem12(int a) {
        int b = 0;
        while (a != 0) {
            b = b * 10 + a % 10;
            a = a / 10;
        }
        System.out.println(b);
        return b;
    }
    public static void main(String[] args) {
        System.out.println(problem1());
        System.out.println(problem2());
        System.out.println(problem3());
        System.out.println(problem4());
        problem5();
        problem6();
        problem7();
        problem8();
        problem9();
        problem10();
        problem11();
        problem12(124567);
    }
}

